<?php

include_once 'Super_Model_Admin.php';

class Admin_Model_Cats extends Super_Model_Admin {

    function getCats($title='') {
        $cats = $this->selectAss('categories', '*', ($title ? ' AND `title` LIKE "%'. addslashes($title).'%"' :''), '`parent_id`,`order_by`');
        $result = array();
        if (is_array($cats) && count($cats)) {
            foreach ($cats as $cat) {
                if (empty($cat['parent_id']))
                    $result[$cat['id']] = $cat;
                else
                    $result[$cat['parent_id']]['child'][] = $cat;
            }
        }
        if ($result) {
            return $result;
        }
        return false;
    }

}